What might go wrong inside the outer try{}
block
which would cause an exception?
(1) One of the files might not open. (2) There might be an error in reading from a file. (3) There might be an error in writing to a file. (4) One of the files might not close.
All of those problems are IOExceptions
so the outer try{}
could catch them all
with one catch{}
block.
But this one block would not be very specific about
which type of error it caught.
The constructors for FileInputStream
and FileOutputStream
throw FileNotFoundException
when there is a problem.
Its catch{}
block
should preceed the one for IOException
.
Here is the program so far:
. . . . try { instr = outstr = try { } catch ( EOFException eof ) { } } catch( ______________________ ) { } catch( ______________________ ) { }
Fill in the blanks.